<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>常用的标签</title>
</head>
<body>
<h1>if</h1>
{% if age == 12 %}
    <p>12</p>
{% elif age == 15 %}
    <p>13</p>
{% else %}
    <p>18</p>
{% endif %}

<h1>for</h1>
{#不存在countinue和break#}
<table>
    <thead>
    <tr>
        <th>序号</th>
        <th>名称</th>
        <th>作者</th>
    </thead>
    <tbody>
        {% for book in books reversed %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ book.name }}</td>
                <td>{{ book.author }}</td>
            </tr>
        {% empty %}
            <tr>
                <td>如果for中books什么没有会执行此</td>
            </tr>
        {% endfor %}
    </tbody>
</table>

<h1>with 定义变量</h1>
{% with name=books.1.name %}
    <p> {{ name }} </p>
{% endwith %}

<h1>url</h1>
<a href="{% url 'movie:movie_list' %}">百度</a>
<a href="{% url 'movie:movie_detail' '1' %}">电影细节</a>
<a href="{% url 'movie:movie_detail' movie_id=1 %}">电影细节2</a>
</body>
</html>